package cn.maxhou.sl2.factory;

import cn.maxhou.sl1.dao.PetDao;
import cn.maxhou.sl1.dao.impl.PetDaoMySQLImpl;
import cn.maxhou.sl2.dao.impl.PetDaoOracleImpl;

public class PetDaoFactpry {
    //此默认名称可以通过读取properties配置文件进行修改
    public static String defaultBeanName = "PetDaoOracleImpl";

    /**
     * 负责根据名称获取对应的PetDao实现对象
     *
     * @param beanName
     * @return
     */
    public static PetDao getInstance(String beanName) {
        PetDao petDao = null;
        switch (beanName) {
            case "PetDaoOracleImpl":
                petDao = new PetDaoOracleImpl();
                break;
            case "PetDaoMysqlImpl":
                petDao = new PetDaoMySQLImpl();
                break;
            default:
                throw new RuntimeException("未找到" + beanName + "对应的对象");
        }
        return petDao;
    }
}
